package com.example.javafx.simple;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class TitledPaneExample extends Application {

    @Override
    public void start(Stage primaryStage) {
        // 创建一个 TitledPane
        TitledPane titledPane = new TitledPane();
        titledPane.setText("Click to Expand");

        // 设置面板内容
        VBox content = new VBox();
        content.getChildren().add(new Label("This is the content inside the TitledPane."));
        titledPane.setContent(content);

        // 设置初始状态为展开或折叠
        titledPane.setExpanded(true);  // 默认展开

        // 将 TitledPane 添加到布局
        VBox root = new VBox(titledPane);

        Scene scene = new Scene(root, 300, 200);
        primaryStage.setTitle("TitledPane Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}